package com.ruoyi.energy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.energy.domain.QyStatisticsReport;
import com.ruoyi.energy.service.IQyStatisticsReportService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 统计报送Controller
 *
 * @author cjie
 * @date 2021-08-02
 */
@Api(tags = " 统计报送")
@RestController
@RequestMapping("/qyStatisticsReport")
public class QyStatisticsReportController extends BaseController {
    @Autowired
    private IQyStatisticsReportService qyStatisticsReportService;

    /**
     * 查询统计报送列表
     */
    @ApiOperation(value="查询统计报送列表", notes="查询统计报送列表")
    @PreAuthorize(hasPermi = "energy:qyStatisticsReport:list")
    @GetMapping("/list")
    public TableDataInfo list(QyStatisticsReport qyStatisticsReport) {
        startPage();
        List<QyStatisticsReport> list = qyStatisticsReportService.selectQyStatisticsReportList(qyStatisticsReport);
        return getDataTable(list);
    }

    /**
     * 导出统计报送列表
     */
    @ApiOperation(value="导出统计报送列表", notes="导出统计报送列表")
    @PreAuthorize(hasPermi = "energy:qyStatisticsReport:export")
    @Log(title = "统计报送", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QyStatisticsReport qyStatisticsReport) throws IOException {
        List<QyStatisticsReport> list = qyStatisticsReportService.selectQyStatisticsReportList(qyStatisticsReport);
        ExcelUtil<QyStatisticsReport> util = new ExcelUtil<QyStatisticsReport>(QyStatisticsReport.class);
        util.exportExcel(response, list, "统计报送数据");
    }
    /**
     * 获取统计报送详细信息
     */
    @ApiOperation(value="获取统计报送详细信息", notes="获取统计报送详细信息")
    @PreAuthorize(hasPermi = "energy:qyStatisticsReport:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(qyStatisticsReportService.selectQyStatisticsReportById(id));
    }

    /**
     * 新增统计报送
     */
    @ApiOperation(value="新增统计报送", notes="新增统计报送")
    @PreAuthorize(hasPermi = "energy:qyStatisticsReport:add")
    @Log(title = "统计报送", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QyStatisticsReport qyStatisticsReport) {
        return toAjax(qyStatisticsReportService.insertQyStatisticsReport(qyStatisticsReport));
    }

    /**
     * 修改统计报送
     */
    @ApiOperation(value="修改统计报送", notes="修改统计报送")
    @PreAuthorize(hasPermi = "energy:qyStatisticsReport:edit")
    @Log(title = "统计报送", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QyStatisticsReport qyStatisticsReport) {
        return toAjax(qyStatisticsReportService.updateQyStatisticsReport(qyStatisticsReport));
    }

    /**
     * 删除统计报送
     */
    @ApiOperation(value="删除统计报送", notes="删除统计报送")
    @ApiImplicitParam(name = "ids", value = "统计报送ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:qyStatisticsReport:remove")
    @Log(title = "统计报送", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(qyStatisticsReportService.deleteQyStatisticsReportByIds(ids));
    }
}
